package com.liao.badminton.handler;


import com.liao.badminton.handler.encode.TransferStandardDecode;
import com.liao.badminton.handler.encode.TransferStandardEncode;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

/**
 * @author Gjing
 * <p>
 * netty服务初始化器
 **/
public class ServerChannelMyselfInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) {
        //添加编解码
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast(new TransferStandardEncode());   //自定义的编解码，客户端怎么办
        pipeline.addLast(new TransferStandardDecode()); //自定义的编解码，客户端怎么办
        pipeline.addLast(new NettyServerMyselfHandler());
        pipeline.addLast(new IdleStateHandler(5, 0, 0));

    }
}